package com.nowcoder;

import java.util.Scanner;

public class KSmallestNumber {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int k = scanner.nextInt();
            // 数组中元素的个n的范围[1,1000]， 数组中所有元素的值val的范围[1,10000]
            int[] arr = new int[10001];
            for (int i = 0; i < n; i++) {
                arr[scanner.nextInt()]++;
            }
            // 打印输出结果
            System.out.println(solver(k, arr));
        }
    }

    public static String solver(int k, int[] arr) {
        StringBuilder builder = new StringBuilder();
        for (int i = 1; i <= 10000; i++) {
            while (arr[i] > 0 && k > 0) {
                builder.append(" ").append(i);
                k--;
                arr[i]--;
            }
        }
        return builder.substring(1);
    }
}
